<%@page import="com.yymmarket.framework.PagingBean,com.yymmarket.forum.util.ConstantUtil,com.yymmarket.forum.util.SessionUtil,com.yymmarket.forum.util.LevelUtil,com.yymmarket.forum.cache.ForumCache,com.yymmarket.forum.admin.AdminBean,com.yymmarket.forum.util.BaseUtil,com.yymmarket.forum.util.DateUtil,com.yymmarket.util.StringUtil,com.yymmarket.forum.bbs.*,java.util.List,com.yymmarket.forum.bbs.ContentService,com.yymmarket.forum.bbs.BBSService,com.yymmarket.framework.WebAction"%><%@ 
page contentType="text/vnd.wap.wml;charset=utf-8"%><%
response.setHeader("Cache-Control","no-cache");
WebAction webAction = new WebAction(request,response);

int id = webAction.getParameterInt("id");
int p1 = webAction.getParameterInt("p1");
BBSService bbs = BBSService.getInstance();
ContentService contentService = ContentService.getInstance();
ContentBean content = contentService.getContentById(id);
content.incrementRead();
ContentReplyService replyService = ContentReplyService.getInstance();
int fid = content.getBbsId();

int p = webAction.getParameterInt("p");
int count = content.getReplyCount();
int limit = 10;
int start = p * limit;

boolean asc = false;

List<ContentReplyBean> list = content.getReplyIdList(start,limit,asc);//replyService.getReplysByContentId(id,start,limit);
PagingBean paging = new PagingBean(webAction,count,limit,"p");
//level==1?"沙发":level==2?"板凳":(level==3?"地板":
Integer uid = SessionUtil.getSessionUserId(request);
//获取用户权限
AdminBean adminBean = ForumCache.getAdminBean(LevelUtil.TYPE_BBS,fid,uid);

%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="<%=StringUtil.toWml(content.getTitle()) %>">
<p><%= BaseUtil.top(request,response) %>楼主:<%=StringUtil.toWml(content.getUserName()) %>(<%=DateUtil.converDateToBefore(content.getCreateTime(),"M-d/h:m")%>)<br/>
<%if(p==0){%><%=StringUtil.toWml(content.getContent()) %><%} %><br/>
<%if(adminBean != null) {
	
	if(adminBean.getAdminLevel()>=LevelUtil.BBS_LEVEL_FUBANZHU) {
		if(content.getType()==0) {
%><a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=prime&amp;value=1">+精</a>|<%
} else { 
%><a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=prime&amp;value=0">-精</a>|<%
} 
		if(content.getReadonly()==0) {
%><a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=lock&amp;value=1">+锁</a><%
		} else {
%><a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=lock&amp;value=0">-锁</a><%
		}
}
	if(adminBean.getAdminLevel()>=LevelUtil.BBS_LEVEL_BANZHU) {
		if(content.getMarkTop()==0) {
%>|<a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=top&amp;value=1">+顶</a><%
		} else if(content.getMarkTop()==1) {
%>|<a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=top&amp;value=0">-顶</a><%
		}
	}
} 
	if(content.getUserId()==uid||adminBean!=null&&adminBean.getAdminLevel()>=LevelUtil.BBS_LEVEL_BANZHU) {
%>|<a href="result.jsp?id=<%=id%>&amp;fid=<%=fid%>&amp;action=delete">删</a>|<a href="edit.jsp?id=<%=id%>&amp;fid=<%=fid %>">续写</a>|<a href="editX.jsp?id=<%=id%>&amp;fid=<%=fid %>">编辑</a><br/><%
	}

	for(int i = 0;i<list.size();i++) {
		ContentReplyBean bean = list.get(i);
%><%if(asc){%><%=i+1 + p*limit %><%}else{ %><%=count-(i + p*limit) %><%} %>.<a href="<%=bean.getUserId()%>"><%=StringUtil.toWml(bean.getUserName()) %></a>:<%
if(bean.getToUserId()>0&&bean.getToUserId()!=uid) {
%>回:<%=StringUtil.toWml(bean.getToUserName()) %>,<%
}

if(bean.getDeleteMark()==1){%>(已删除)(<%=DateUtil.converDateToBefore(bean.getCreateTime(),"M-d/h:m")%>)<%} else {%><%=StringUtil.toWml(bean.getReplyContent()) %>(<%=DateUtil.converDateToBefore(bean.getCreateTime(),"M-d/h:m")%>)<%if(uid==bean.getUserId()||adminBean!=null&&adminBean.getAdminLevel()>=LevelUtil.BBS_LEVEL_BANZHU) {%><a href="replyDelete.jsp?id=<%=bean.getId()%>&amp;cid=<%=id %>&amp;fid=<%=fid %>&amp;p1=<%=p1 %>&amp;p=<%=p%>">删</a><%} %><%}%><br/><%
	}
	
	if(!content.isReadOnly()) {
%><%=paging.shuzifenyeAndShangXia2(response.encodeURL("content.jsp?id="+id+"&amp;fid="+fid+"&amp;p1="+p1),true,"|",response) %>
回:<select name="toUid">
<option value="0">楼主</option>
<%for(int i = 0;i<list.size();i++) {
	
	ContentReplyBean bean = list.get(i); 
	if(bean.getUserId()!=uid) {
		if(asc){
			int level = i+1 + p*limit;
	%><option value="<%=bean.getUserId() %>"><%=""+level+"楼" %></option><%
		} else {
			int level = count-(i + p*limit);
		%><option value="<%=bean.getUserId() %>"><%=""+level+"楼" %></option><%
		}
		}
} 
%></select><br/>
<input type="text" name="c" value=""/><br/>
<anchor>回复<go href="reply.jsp?fid=<%=fid%>&amp;cid=<%=id %>&amp;p=<%=p %>&amp;p1=<%=p1 %>" method="post">
<postfield name="toUid" value="$toUid" />
<postfield name="c" value="$c" />
</go></anchor><br/><%} 
%><a href="forum.jsp?id=<%=fid %>&amp;p=<%=p1 %>">&lt;返回<%=bbs.getBBSBeanById(content.getBbsId()).getTitle() %></a><br/>
<a href="index.jsp">&lt;&lt;论坛首页</a><br/>
<%= BaseUtil.bottom(request,response) %></p>
</card>
</wml>